<?xml version="1.0" encoding="ISO-8859-1" ?>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:af="http://myfaces.apache.org/trinidad"
	xmlns:afh="http://myfaces.apache.org/trinidad/html">

   <af:spacer height="10px"/>
   <div class="workingParticipantsOptionFrame">
       <af:panelCaptionGroup captionText="#{localeBundle.chooseWorkingRoles}">
          <af:selectManyShuttle id="workingParticipantsShuttle" styleClass="workingParticipantsOption" size="10" 
            value="#{portalHeader.selectedParticipants}" ondblclick="check(this, window.document.forms['processPortalForm']);">
            <f:selectItems value="#{portalHeader.allParticipantsAndGroups}"/>
          </af:selectManyShuttle>
       </af:panelCaptionGroup>
       
       
       <af:panelButtonBar halign="center">
            <af:commandButton id="applyChanges" action="success" onclick="return validOptions(window.document.forms['processPortalForm']);"
                text="#{commonMsg.apply}" actionListener="#{portalHeader.applyOptions}">
                <af:setActionListener from="#{portalHeader.worklistPage}" to="#{portalHeader.processPortalSession.currentPage}"/>
            </af:commandButton>
            <af:commandButton id="cancel" action="success"
                text="#{commonMsg.cancel}" immediate="true">
                <af:setActionListener from="#{portalHeader.worklistPage}" to="#{portalHeader.processPortalSession.currentPage}"/>
            </af:commandButton>
       </af:panelButtonBar>
   </div>
   <script type="text/javascript" language="javascript">
   // <![CDATA[
      
      function check(source, tform)
      {
         if(source.id.length == 0)
         { 
            var proxy = new TrShuttleProxy("options:workingParticipantsShuttle", tform.name);
            if(proxy != null && proxy.getItemCount(false) == 0)
            {
               proxy.move(true, false);
               showFacesMessage('globalPortalMessage', 'options:workingParticipantsShuttle',
                    '#{localeBundle.chooseWorkingRoles}', '#{localeBundle.selectAtLeastOneEntry}', null);
            }
            else
            {
              removeFacesMessages('globalPortalMessage', 'options:workingParticipantsShuttle')
            }
         }
      }
      
      function validOptions(tform)
      {
        var proxy = new TrShuttleProxy("options:workingParticipantsShuttle", tform.name);
        if(proxy != null && proxy.getItemCount(false) == 0)
        {
          showFacesMessage('globalPortalMessage', 'options:workingParticipantsShuttle',
            '#{localeBundle.chooseWorkingRoles}', '#{localeBundle.selectAtLeastOneEntry}', null);
          return false;
        }
        return true;
      }
   // ]]>
   </script>
   
</ui:composition>